{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "using GR\n",
    "GR.__init__()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "using PackageCompiler\n",
    "compile_incremental(\"GR\", joinpath(dirname(pathof(GR)), \"..\", \"examples\", \"snoop.jl\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "using Random\n",
    "rng = MersenneTwister(1234);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 0:π/100:2π\n",
    "y = sin.(x)\n",
    "plot(x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = LinRange(0, 1, 51)\n",
    "y = x .- x.^2\n",
    "scatter(x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sz = LinRange(50, 300, length(x))\n",
    "c = LinRange(0, 255, length(x))\n",
    "scatter(x, y, sz, c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "stem(x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "histogram(randn(rng, 10000))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot(randn(50))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "oplot(randn(50,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = LinRange(0, 30, 1000)\n",
    "y = cos.(x) .* x\n",
    "z = sin.(x) .* x\n",
    "plot3(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "angles = LinRange(0, 2pi, 40)\n",
    "radii = LinRange(0, 2, 40)\n",
    "polar(angles, radii)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 2 .* rand(rng, 100) .- 1\n",
    "y = 2 .* rand(rng, 100) .- 1\n",
    "z = 2 .* rand(rng, 100) .- 1\n",
    "scatter3(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "c = 999 .* rand(rng, 100) .+ 1\n",
    "scatter3(x, y, z, c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = randn(rng, 100000)\n",
    "y = randn(rng, 100000)\n",
    "hexbin(x, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 8 .* rand(rng, 100) .- 4\n",
    "y = 8 .* rand(rng, 100) .- 4\n",
    "z = sin.(x) .+ cos.(y)\n",
    "contour(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = LinRange(-2, 2, 40)\n",
    "y = LinRange(0, pi, 20)\n",
    "z = sin.(x') .+ cos.(y)\n",
    "contour(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 8 .* rand(rng, 100) .- 4\n",
    "y = 8 .* rand(rng, 100) .- 4\n",
    "z = sin.(x) .+ cos.(y)\n",
    "contourf(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = LinRange(-2, 2, 40)\n",
    "y = LinRange(0, pi, 20)\n",
    "z = sin.(x') .+ cos.(y)\n",
    "contourf(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 8 .* rand(rng, 100) .- 4\n",
    "y = 8 .* rand(rng, 100) .- 4\n",
    "z = sin.(x) + cos.(y)\n",
    "tricont(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 8 .* rand(rng, 100) .- 4\n",
    "y = 8 .* rand(rng, 100) .- 4\n",
    "z = sin.(x) .+ cos.(y)\n",
    "surface(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = LinRange(-2, 2, 40)\n",
    "y = LinRange(0, pi, 20)\n",
    "z = sin.(x') .+ cos.(y)\n",
    "surface(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 8 .* rand(rng, 100) .- 4\n",
    "y = 8 .* rand(rng, 100) .- 4\n",
    "z = sin.(x) .+ cos.(y)\n",
    "GR.trisurf(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 8 .* rand(rng, 100) .- 4\n",
    "y = 8 .* rand(rng, 100) .- 4\n",
    "z = sin.(x) .+ cos.(y)\n",
    "wireframe(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = LinRange(-2, 2, 40)\n",
    "y = LinRange(0, pi, 20)\n",
    "z = sin.(x') .+ cos.(y)\n",
    "wireframe(x, y, z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create example data\n",
    "x = LinRange(-2, 2, 40)\n",
    "y = LinRange(0, pi, 20)\n",
    "z = sin.(x') .+ cos.(y)\n",
    "heatmap(z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "imshow(z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = LinRange(-1, 1, 40)\n",
    "v = 1 .- (s .^ 2 .+ (s .^ 2)' .+ reshape(s,1,1,:) .^ 2) .^ 0.5\n",
    "isosurface(v, isovalue=0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "GR.GR3.terminate()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "volume(randn(rng, 50, 50, 50))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "N = 1_000_000\n",
    "x = randn(rng, N)\n",
    "y = randn(rng, N)\n",
    "shade(x, y)"
   ]
  }
 ],
 "metadata": {
  "@webio": {
   "lastCommId": null,
   "lastKernelId": null
  },
  "kernelspec": {
   "display_name": "Julia 1.3.1",
   "language": "julia",
   "name": "julia-1.3"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "1.3.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
